package com.ruoyi.web.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.Judgmentquestions;
import com.ruoyi.system.domain.MultipleChoiceQuestions;
import com.ruoyi.system.service.IJudgmentquestionsService;
import com.ruoyi.system.service.IMultipleChoiceQuestionsService;
import com.ruoyi.web.controller.Entity.UsertopicUnitEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 单元测试接口
 */
@Controller
@RequestMapping("/system/usertopicunit")
public class UsertopicUnitController {
    @Autowired
    private IJudgmentquestionsService judgmentquestionsService;
    @Autowired
    private IMultipleChoiceQuestionsService multipleChoiceQuestionsService;

    @PostMapping("/getList")
    @ResponseBody
    public AjaxResult getUnititem(@RequestParam("typeId") Long typeId) {
        MultipleChoiceQuestions multipleChoiceQuestions = new MultipleChoiceQuestions();
        Judgmentquestions judgmentquestions = new Judgmentquestions();
        judgmentquestions.setTopicName(typeId);
        multipleChoiceQuestions.setTopicName(typeId);
        List<Judgmentquestions> judgmentquestionslist = judgmentquestionsService.selectJudgmentquestionsList(judgmentquestions);
        List<MultipleChoiceQuestions> questionsList = multipleChoiceQuestionsService.selectMultipleChoiceQuestionsList(multipleChoiceQuestions);
        UsertopicUnitEntity usertopicUnit=new UsertopicUnitEntity(judgmentquestionslist,questionsList);
        return AjaxResult.success(usertopicUnit);
    }
    @PostMapping("/getList2")
    @ResponseBody
    public AjaxResult getList(){
        MultipleChoiceQuestions multipleChoiceQuestions = new MultipleChoiceQuestions();
        List< MultipleChoiceQuestions> list=multipleChoiceQuestionsService.selectMultipleChoiceQuestionsList(multipleChoiceQuestions);
        Collections.shuffle (list);
        return AjaxResult.success(list);
    }
}
